﻿Imports System.Data.OleDb
Imports System.Xml
Imports System.ServiceModel.Syndication




Public Class Rss
    Inherits System.Web.UI.Page



    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

        Dim conn As OleDbConnection
        Dim app_path As String
        Dim xmltxtwtr As XmlTextWriter
        Dim cmd As OleDbCommand
        Dim datareader As OleDbDataReader
        app_path = System.AppDomain.CurrentDomain.BaseDirectory()
        conn = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\Macrography.accdb;Persist Security Info=True")
        xmltxtwtr = New XmlTextWriter(Response.OutputStream, Encoding.UTF8)
        xmltxtwtr.WriteStartDocument()
        xmltxtwtr.WriteStartElement("rss")
        xmltxtwtr.WriteAttributeString("version", "2.0")
        xmltxtwtr.WriteStartElement("channel")
        xmltxtwtr.WriteElementString("title", "Rss Feed")
        conn.Open()

        cmd = New OleDbCommand("select Img_Id, Date_added, Cat_Id from Images", conn)
        datareader = cmd.ExecuteReader()
        While datareader.Read()
            xmltxtwtr.WriteStartElement("item")
            xmltxtwtr.WriteElementString("Img_Id", datareader("Im_Id").ToString())
            xmltxtwtr.WriteElementString("Date_added", datareader("Date_added").ToString())
            xmltxtwtr.WriteElementString("Cat_Id", datareader("Cat_Id").ToString())
           
            xmltxtwtr.WriteEndElement()
        End While
        xmltxtwtr.WriteEndElement()
        xmltxtwtr.WriteEndElement()
        xmltxtwtr.WriteEndDocument()
        xmltxtwtr.Flush()
        xmltxtwtr.Close()
        conn.Close()
        Response.End()
    End Sub
End Class